package controllers;

import java.util.List;
import models.NodeConfig;
import play.Logger;
import play.mvc.Controller;

public class NodeConfigController extends Controller {
    
    public static void nodes() {
        List<models.NodeConfig> nodeConfigList = models.NodeConfig.findAll();
        render(nodeConfigList);
    }
    
    public static void setPropertyValue(Long id, String key) {
        Logger.debug("Id:%s Ip: %s", id, key);
        NodeConfig nodeconfig = NodeConfig.getProperty(id);
        if(nodeconfig == null) {
            Logger.error("Missing node ip");
        }
        else {
            nodeconfig.setNodeIP(key);
            nodeconfig.save();
        }
        nodes();
    }
}
